package part01_七大原则.p04_里氏原则;

/**
 * @ClassName: Liskov02
 * @Author: AllenSun
 * @Date: 2019/12/3 0:38
 */
public class Liskov02 {
    public static void main(String[] args) {

        AA aa = new AA();
        System.out.println("11-3="+aa.func01(11,3));
        System.out.println("1-8="+aa.func01(1,8));

        System.out.println("---------------------");

        BB bb = new BB();
        System.out.println("11+3="+bb.func01(11,3));
        System.out.println("1+8="+bb.func01(1,8));
        System.out.println("11+3+9="+bb.func02(11,3));

        System.out.println("11-3="+bb.func03(11,3));

    }
}

//父类
class Base{

}

//子类AA，实现减法
class AA extends Base{
    //减法
    public int func01(int num01, int num02){
        return num01-num02;
    }
}

//子类BB，
class BB extends Base{
    private AA aa=new AA();

    //加法
    public int func01(int a, int b){
        return a+b;
    }

    public int func02(int a, int b){
        return func02(a,b)+9;
    }

    public int func03(int a, int b){
        return this.aa.func01(a,b);
    }
}